package FinalProject



import grails.test.mixin.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Review)
@Mock([Game,Platform,SiteUser])

class ReviewTests {

    void testSomething() {
        SiteUser s1 = new SiteUser()
        s1.name = "Danny Schaefer"
        s1.dateJoined = new Date()
        s1.save(failOnError: true)
        Game g1 = new Game(name:"Goldeneye", releaseDate: "8/25/1997")
        g1.save(failOnError:true)
        Review r1 = new Review(reviewText:"This is the story of a girl who cried a river and drowned the whole world", siteUser: s1, game:  g1)
        r1.save(failOnError: true)
        assertEquals(r1.reviewText,"This is the story of a girl who cried a river and drowned the whole world" )
        assertEquals(s1.reviews.size(), 1)
        s1.post("I asked her her name she said blah blah blah", g1)
        assertEquals(s1.reviews.size(), 2)
        def reviews = Review.findAllByReviewTextLike("This is the story" + "%")
        assertEquals(reviews.size(), 1)
    }
}
